package com.qf.serevice.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.entity.PatientMedicineInfo;
import com.qf.mapper.OrderMapper;
import com.qf.pojo.BaseResult;
import com.qf.serevice.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    BaseResult baseResult = new BaseResult();
    @Autowired
    OrderMapper orderMapper;
    @Override
    //查询所有患者的取药信息
    public BaseResult findAllOrder(Integer page, Integer size, String name) {
        PageHelper.startPage(page,size);
        String pname = "%"+name+"%";
        List<PatientMedicineInfo> allOrder = orderMapper.findAllOrder(pname);
        if (allOrder!=null){
            PageInfo<PatientMedicineInfo> of = PageInfo.of(allOrder);
            baseResult.setData(of.getList());
            baseResult.setCode(1);
            baseResult.setInfo("查询成功");
            baseResult.setTotal(of.getTotal());
            return baseResult;
        }else {
            baseResult.setCode(0);
            baseResult.setInfo("失败");

        }
        return baseResult;
    }
}
